﻿<script>

    var deleteLinkObj;
    var detailLinkObj;
    // delete Link
    $('.delete-link').click(function () {
        deleteLinkObj = $(this);  //for future use
        var deletionTarget = deleteLinkObj[0].name;
        $("#dialog-confirm > p").html("Bạn có chắc chắn muốn xóa: " + deletionTarget + " ?");

        $('#dialog-confirm').dialog({
            autoOpen: true, width: 400, resizable: false, modal: true, //Dialog options
            buttons: {
                "Delete": function () {
                    $.post(deleteLinkObj[0].href, function (data) {  //Post to action
                        if (data == "True") {
                            $(deleteLinkObj).closest('tr').hide("slow") //Hide Row
                        }
                        else {

                            alert("xoa bi loi");
                        }
                    });
                    $(this).dialog("close");
                },
                "Cancel": function () {
                    $(this).dialog("close");
                }
            }
        });
        return false;
    });
    //detail - link
    $('.detail-link').click(function () {
        detailLinkObj = $(this);
        $.get(detailLinkObj[0].href, null, function (data) {
            $("#dialog-detail").html(data);
            $("#dialog-detail").dialog({
                autoOpen: true, width: 500, resizable: false, modal: true, //Dialog options
                buttons: {
                    "Close": function () {
                        $(this).dialog("close");
                    }
                }
            });
        });

        return false;
    })
</script>
<div id="dialog-detail" title="Xem chi tiết!" style="display:none">
</div>
<div id="dialog-confirm" title="Xác nhận xóa!" style="display:none">
    <p></p>
</div>